package com.conference.service.impl;

import com.conference.service.ConferenceListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ConferenceListServiceImpl implements ConferenceListService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<Map<String, Object>> getAllConferences() {
        String sql = "SELECT c.id, c.title, c.start_time, c.status, c.location " +
                    "FROM conference c " +
                    "ORDER BY c.start_time DESC";
        return jdbcTemplate.queryForList(sql);
    }

    @Override
    public List<Map<String, Object>> getPublishedConferences() {
        String sql = "SELECT c.id, c.title, c.start_time, c.status, c.location " +
                    "FROM conference c " +
                    "WHERE c.status = 1 " +
                    "ORDER BY c.start_time DESC";
        return jdbcTemplate.queryForList(sql);
    }

    @Override
    public List<Map<String, Object>> getUpcomingConferences() {
        String sql = "SELECT c.id, c.title, c.start_time, c.status, c.location " +
                    "FROM conference c " +
                    "WHERE c.status = 1 " +
                    "AND c.start_time > NOW() " +
                    "ORDER BY c.start_time ASC";
        return jdbcTemplate.queryForList(sql);
    }
} 